﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/admin.Master" Inherits="System.Web.Mvc.ViewPage<_619BJP.Models.ProductModel>" validateRequest="false"  %>
<asp:Content ID="ContentHead" ContentPlaceHolderID="head" runat="server">
    <script src="../../Scripts/Component/jquery-1.4.4.min.js" type="text/javascript"></script>
    <script src="../../Scripts/Global/basedata.js" type="text/javascript"></script>
    <script src="../../Scripts/Component/kindeditor/kindeditor.js" type="text/javascript"></script>
    <script src="../../Scripts/Instance/admin/articleupload.js" type="text/javascript"></script>
    <link href="../../Content/css/Instance/admin/articleupload.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        $(document).ready(function () {

            var editor;
            var html;

            glInitOption($("#article_category").get(0), gvArticleCategory, 0);
            $("#article_category").change(function () {
                $("#category").val($("#article_category").val() == 0 ? null : $('#article_category :selected').val());
            });

            KindEditor.ready(function (K) {
                editor = K.create('textarea[name="article_content"]', {
                    allowFileManager: true
                });
                K('input[name=btnUpload]').click(function (e) {
                    if ($("#article_title").val() == "") {
                        alert($("#article_title").val());
                        alert("百科名称不能为空！");
                        return false;
                    }
                    if ($("#article_category").val() == "" || $("#article_category").val() == 0) {
                        alert($("#category").val());
                        alert("百科类别不能为空！");
                        return false;
                    }

                    $.post(encodeURI("/Admin/NewArticle"), { 
                            article_title: $("#article_title").val(),
                            category: $("#category").val(),
                            content: editor.html().toString().trim()
                        },
                        function(data) {
                            if (data != null && data["Success"]) {
                                alert(data["info"]);
                                location.reload();
                            }
                            else {
                                alert(data["Info"]);
                            }
                        }, "json");
                });
            });
        });
    </script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<div class="form_panel">
    <div class="title">添加百科</div>
        <ul class="feild_list">
            <li id="article_name" >
                <label>百科名称<span class="redcolor">*</span></label>
                <input type="text" id="article_title" name="article_title" />
            </li>
            <li>
                <label>所属类别<span class="redcolor">*</span></label>
                <select id="article_category"></select><input id="category" name="category" type="hidden" /> 
            </li>
            <li id="article_content" >
                <textarea id="txt_content" cols="100" rows="8" name="article_content">
                </textarea>
            </li>
            <li>
                <input type="button" id="btnUpload" name="btnUpload" value="提交"/>
            </li>
        </ul>
    </div>

</asp:Content>

